package controllers

import (
	"github.com/astaxie/beego"
	"github.com/sirupsen/logrus"
	"learn-otp/dao"
)

var userDao dao.UserDao
var logDao dao.LogDao

type BaseController struct {
	beego.Controller
}

func (c *BaseController) Get() {
	c.TplName = "index.html"
}

func (c *BaseController) writeError(err error) {
	logrus.Error(err)

	rst := Response{
		Success: false,
		Msg:     err.Error(),
	}

	c.Data["json"] = rst
	c.ServeJSON()
}

type Response struct {
	Data    interface{} `json: "data"`
	Success bool        `json: "Success"`
	Total   int64       `json: "Total"`
	Msg     string      `json: "Msg"`
}
